package com.hpeng.util;

import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Component;

import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
@Component("toOutExcel")
public class ToOutExcel {
	public boolean OutToExcel(String[] key,String[] value,String url){
		System.out.println(url+".xls");
		try {
			WritableWorkbook book = Workbook.createWorkbook(new File(url+".xls"));
			WritableSheet sheet = book.createSheet("第一页",0);
			Label label = null;
			for(int i = 0; i < key.length;i++){
				label = new Label(0,i,key[i]);
				sheet.addCell(label);
				label = new Label(1,i,value[i]);
				sheet.addCell(label);
			}
			book.write();
			book.close();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (RowsExceededException e) {
			e.printStackTrace();
		} catch (WriteException e) {
			e.printStackTrace();
		}
		return true;
	}
}
